package algorithm.recursive;

/**
 * @author keyer
 * @Description : 斐波那契数列
 * Created by cyd on 2021-06-15 09:16:17
 */
public class FibonacciTest {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        fib(50);
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }

    public static void printFib(int n) {
        while (n > -1) {
            Integer fib = fib(n);
            System.out.println(n + " --- " + fib);
            n--;
        }
    }
    static Integer i=0;

    public static Integer fib(int n) {
        if (n == 0) {
            return 0;
        } else if (n == 1) {
            return 1;
        }
        if (n > 1) {
            return fib(n - 1) + fib(n - 2);
        }
        throw new RuntimeException("初始值不符合要求");
    }
}
